package com.guaju.yueshangLife.widget.dilivery;

import android.app.Activity;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;

import com.guaju.yueshangLife.R;
import com.guaju.yueshangLife.bean.OrderDetailBean;
import com.guaju.yueshangLife.databinding.ItemDiliveryProgressBinding;

public class LineItem extends FrameLayout {

    private LayoutInflater layoutInflater;
    private ItemDiliveryProgressBinding binding;
    private boolean isFirst = false;
    private boolean isLast = false;


    public LineItem(Context context) {
        super(context);
        init();
    }

    public LineItem(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public LineItem(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        layoutInflater = LayoutInflater.from(getContext());
        binding = DataBindingUtil.inflate(layoutInflater, R.layout.item_dilivery_progress, this, false);
        this.addView(binding.getRoot());
    }

    public void setProgress(OrderDetailBean.DataBean.ShipDataBean.DetailBean bean) {
        binding.tvProgress.setText(bean.getRemark());
        binding.ivProgressStatus.setImageResource(R.drawable.process_grey);
        binding.tvProgressTime.setText(bean.getDatetime());
        binding.lineUp.setVisibility(View.VISIBLE);
        binding.lineDown.setVisibility(View.VISIBLE);
        if (isFirst) {
            binding.lineDown.setVisibility(View.GONE);
        }
        if (isLast) {
            binding.lineUp.setVisibility(View.GONE);
            binding.ivProgressStatus.setImageResource(R.drawable.progress_ing);
        }
    }

    public void setIsFirst(boolean value) {
        this.isFirst = value;
    }

    public void setIsLast(boolean value) {
        this.isLast = value;
    }
}
